package lab8;
/*
 * Bai1
 * @author: nguyentrongtri
 * @created date: 2014/06/07
 */

public class LinkedListTest {
	public static void main(String[] args) {
	    //List of Integer
	    System.out.println("I. Demo for List of Integer");
	    LinkedList<Integer> listInt = new LinkedList<Integer>();
        System.out.println("1. Init:" + listInt);
        listInt.addFirst(3);
        listInt.addFirst(1);
        listInt.addLast(4);
        System.out.println("2. Addfirst 3 " +
        		"then addfirst 1 and 4: " + listInt);
        listInt.removeFirst();
        System.out.println("3. After remove first: " + listInt);
        
        //List of Student
        System.out.println("\nII. Demo for List of Student");
        Student s1 = new Student(1, "Ty");
        Student s2 = new Student(2, "Suu");
        Student s3 = new Student(3, "Dan");
        Student s4 = new Student(4, "Meo");
		Student s5 = new Student(5, "Thin");
		Student s6 = new Student(6, "Ti");
	    
		List<Student> list = new LinkedList<Student>();
		System.out.println("1. Init:" + list);
		
		list.addFirst(s3);
		list.addFirst(s1);
		System.out.println("2. Addfirst 3 then 1: " + list);
		
		list.addLast(s4);
		list.addLast(s6);
		System.out.println("3. AddLast 4 then 6: " + list);
		
		list.insertAfter(s1, s2);
		System.out.println("4. Insert s2 after s1: " + list);
		
		list.insertBefore(s6, s5);
		System.out.println("5. Insert s5 before s6: " + list);
		
		list.remove(s3);
		System.out.println("6. Remove s3: " + list);
		
      list.removeFirst();
      System.out.println("7. Remove first: " + list);
      
		list.removeLast();
		System.out.println("8. Remove last: " + list);
		
	}

}
